package cn.dapeng.features;

public class DeadLock_T01 {

     private static Object o1 = new Object();

    private static Object o2 = new Object();

    public static void m1() {
        synchronized (o1) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (o2) {
                System.out.println("m1");
            }
        }
    }


    public static void m2() {
        synchronized (o2) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (o1) {
                System.out.println("m2");
            }
        }
    }

    public static void main(String[] args) {

        new Thread(DeadLock_T01::m1).start();

        m2();
    }
}
